/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package searchsort;


public class Main {
    
    private static MyDataBeanArray unorderedArray, orderedArray;

    public static void main(String[] args) {
        
        unorderedArray = makeUnorderedArray ();
        testLinearSearch(3, unorderedArray);
        
        orderedArray = makeOrderedArray ();
        testBinarySearch(4, orderedArray);
        
        //testBubbleSort(unorderedArray);
        
        testQuickSort(unorderedArray);
        
        
    }
    
    private static MyDataBeanArray makeUnorderedArray () {
        
        MyDataBeanArray unorderedArray = new MyDataBeanArray(10);
        unorderedArray.put(new MyDataBean(2,"dato 2"));
        unorderedArray.put(new MyDataBean(1,"dato 1.A"));
        unorderedArray.put(new MyDataBean(3,"dato 3"));
        unorderedArray.put(new MyDataBean(5,"dato 5"));
        unorderedArray.put(new MyDataBean(1,"dato 1.B"));
        unorderedArray.put(new MyDataBean(4,"dato 4"));
        unorderedArray.put(new MyDataBean(1,"dato 1.C"));
        return unorderedArray;
        
    }
    
    private static MyDataBeanArray makeOrderedArray () {
        
        // ascending order
        
        MyDataBeanArray orderedArray = new MyDataBeanArray(10);
        orderedArray.put(new MyDataBean(1,"dato 1"));
        orderedArray.put(new MyDataBean(2,"dato 2"));
        orderedArray.put(new MyDataBean(3,"dato 3"));
        orderedArray.put(new MyDataBean(4,"dato 4"));
        orderedArray.put(new MyDataBean(5,"dato 5"));
        return orderedArray;
        
    }

    private static void testLinearSearch (int key, MyDataBeanArray myArray) {

        MyDataBean dataBean = LinearSearch.search(key, myArray);

    }

    private static void testBinarySearch (int key, MyDataBeanArray myArray) {

        MyDataBean dataBean = BinarySearch.search(key, myArray);

    }
    
    private static void testBubbleSort (MyDataBeanArray array) {
        array.display();
        BubbleSort.sort(array);
        array.display();
    }
    
    private static void testQuickSort (MyDataBeanArray array) {
        array.display();
        QuickSort.sort(array);
        array.display();
    }
    
    
}
